/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jdCargandoListas.java
 *
 * Created on 24/06/2010, 12:41:02 PM
 */

package administracion.helper;

import java.math.BigDecimal;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Renato
 */
public class jdCargandoListas extends javax.swing.JDialog {
    int avance;
    int actual;
    /** Creates new form jdCargandoListas */
    public jdCargandoListas(java.awt.Frame parent, boolean modal,int cantidad) {
        super(parent, modal);
        initComponents();
        avance=100/cantidad;
        this.jlMensaje.setText("Conectando al servidor");
        this.jpbBarra.setIndeterminate(false);
        this.actual=0;
        this.setLocationRelativeTo(null);
        this.setVisible(true);        
    }

    public void avanzar(String mensaje){
        if(this.jpbBarra.isIndeterminate()){
            this.jpbBarra.setIndeterminate(false);
        }
        this.jlMensaje.setText("Cargando "+mensaje+" ...");
        this.actual=this.actual+this.avance;
        this.jpbBarra.setValue(this.actual);
    }

    public void terminar(){
        if(this.actual>0){
            this.actual=100;
        }
        this.jlMensaje.setText("Se Cargo Correctamente!");
        this.jpbBarra.setValue(this.actual);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
        }
        this.dispose();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpbBarra = new javax.swing.JProgressBar();
        jLabel1 = new javax.swing.JLabel();
        jlMensaje = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Cargando Componentes");
        setAlwaysOnTop(true);

        jpbBarra.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jpbBarra.setName("jpbBarra"); // NOI18N

        jLabel1.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel1.setText("Progreso:");
        jLabel1.setName("jLabel1"); // NOI18N

        jlMensaje.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jlMensaje.setName("jlMensaje"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(20, 20, 20)
                            .addComponent(jlMensaje, javax.swing.GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE))
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jpbBarra, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(159, 159, 159)
                        .addComponent(jLabel1)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpbBarra, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jlMensaje, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jlMensaje;
    private javax.swing.JProgressBar jpbBarra;
    // End of variables declaration//GEN-END:variables

}
